package net.zoneland.knowledge.config;

import java.util.Map;
import javax.annotation.PostConstruct;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import com.branchitech.ldap.LdapHandler;
import com.google.common.collect.Maps;

/**
 * uom相关配置.
 * @author zmq
 * @date 2020/8/26 15:34
 */
@Configuration
@ConfigurationProperties(prefix = "ldap")
public class UomConfig {
    private String environment = "zmcctest";
    private String baseDn = "O=zmcc";
    private String serviceUrl;
    private String memberServiceUrl;
    private long executeThreadTimeOut = 3500;
    private long connectTimeOut = 1000;
    private long socketTimeOut = 2000;
    private int threadPoolCoreSize = 20;
    private boolean enableLocalCache = false;
    private String localCachePath = "/app/logs";
    private String loginName = "was-app";
    private String loginPwd = "was-app-pwd";
    private String domain = "ZMCC";
    private String dataServiceUrl = "http://oauommem.zj.chinamobile.com/uom-dataservice/";

    /**
     * 初始化ldapHandler.
     * @return
     */
    @PostConstruct
    public LdapHandler ldapHandler() {
        final Map<String, Object> prop = Maps.newHashMap();
        prop.put("ldap.environment", environment);
        prop.put("ldap.baseDn", baseDn);
        prop.put("ldap.serviceUrl", serviceUrl);
        prop.put("ldap.memberServiceUrl", memberServiceUrl);
        prop.put("ldap.executeThreadTimeOut", executeThreadTimeOut);
        prop.put("ldap.connectTimeOut", connectTimeOut);
        prop.put("ldap.socketTimeOut", socketTimeOut);
        prop.put("ldap.threadPoolCoreSize", threadPoolCoreSize);
        prop.put("ldap.enableLocalCache", enableLocalCache);
        prop.put("ldap.localCachePath", localCachePath);
        prop.put("ldap.loginName", loginName);
        prop.put("ldap.loginPwd", loginPwd);
        return LdapHandler.init(prop);
    }

    public String getEnvironment() {
        return environment;
    }

    public void setEnvironment(String environment) {
        this.environment = environment;
    }

    public String getBaseDn() {
        return baseDn;
    }

    public void setBaseDn(String baseDn) {
        this.baseDn = baseDn;
    }

    public String getServiceUrl() {
        return serviceUrl;
    }

    public void setServiceUrl(String serviceUrl) {
        this.serviceUrl = serviceUrl;
    }

    public String getMemberServiceUrl() {
        return memberServiceUrl;
    }

    public void setMemberServiceUrl(String memberServiceUrl) {
        this.memberServiceUrl = memberServiceUrl;
    }

    public long getExecuteThreadTimeOut() {
        return executeThreadTimeOut;
    }

    public void setExecuteThreadTimeOut(long executeThreadTimeOut) {
        this.executeThreadTimeOut = executeThreadTimeOut;
    }

    public long getConnectTimeOut() {
        return connectTimeOut;
    }

    public void setConnectTimeOut(long connectTimeOut) {
        this.connectTimeOut = connectTimeOut;
    }

    public long getSocketTimeOut() {
        return socketTimeOut;
    }

    public void setSocketTimeOut(long socketTimeOut) {
        this.socketTimeOut = socketTimeOut;
    }

    public int getThreadPoolCoreSize() {
        return threadPoolCoreSize;
    }

    public void setThreadPoolCoreSize(int threadPoolCoreSize) {
        this.threadPoolCoreSize = threadPoolCoreSize;
    }

    public boolean isEnableLocalCache() {
        return enableLocalCache;
    }

    public void setEnableLocalCache(boolean enableLocalCache) {
        this.enableLocalCache = enableLocalCache;
    }

    public String getLocalCachePath() {
        return localCachePath;
    }

    public void setLocalCachePath(String localCachePath) {
        this.localCachePath = localCachePath;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getLoginPwd() {
        return loginPwd;
    }

    public void setLoginPwd(String loginPwd) {
        this.loginPwd = loginPwd;
    }

    /**
     * .
     *
     * @return domain
     */
    public String getDomain() {
        return domain;
    }

    /**
     * .
     *
     * @param domain to set
     */
    public void setDomain(final String domain) {
        this.domain = domain;
    }

    /**
     * .
     *
     * @return dataServiceUrl
     */
    public String getDataServiceUrl() {
        return dataServiceUrl;
    }

    /**
     * .
     *
     * @param dataServiceUrl to set
     */
    public void setDataServiceUrl(final String dataServiceUrl) {
        this.dataServiceUrl = dataServiceUrl;
    }
}
